<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>待办事项列表</title>
</head>

<body>
    <input type="text" id="todoInput" placeholder="输入待办事项">
    <button id="addButton">添加</button>
    <ul id="todoList"></ul>
    <script>
        const addButton = document.getElementById('addButton');
        const todoInput = document.getElementById('todoInput');
        const todoList = document.getElementById('todoList');

        addButton.addEventListener('click', function () {
            const todoText = todoInput.value;
            if (todoText!== '') {
                const listItem = document.createElement('li');
                listItem.textContent = todoText;
                todoList.appendChild(listItem);
                todoInput.value = '';
            }
        });
    </script>
</body>

</html>